package org.phalanx.client.mapeditor;

import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class PhalanxMapSizeSetPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4196638350706949133L;
	JTextField widthField;
	JTextField lengthField;

	public PhalanxMapSizeSetPanel() {
		initializePanel();
		setComponents();
		setInternalPanel();
	}

	private void initializePanel() {
		this.setBackground(Color.black);
		this.setLayout(new GridBagLayout());
	}

	private void setComponents() {
		widthField = new JTextField();
		lengthField = new JTextField();

		widthField.setColumns(4);
		lengthField.setColumns(4);
	}

	private void setInternalPanel() {
		GridBagConstraints constr = new GridBagConstraints();
		constr.gridx = 0;
		constr.gridy = 0;
		constr.fill = GridBagConstraints.BOTH;

		JPanel c = new JPanel();
		c.setLayout(new FlowLayout(FlowLayout.LEFT));
		c.setBackground(Color.black);
		
		c.add(getJLabel("Size: "));
		c.add(Box.createHorizontalStrut(5));
		c.add(getJLabel("L"));
		c.add(lengthField);
		c.add(getJLabel("x"));
		c.add(getJLabel("W"));
		c.add(widthField);

		this.add(c, constr);
	}

	public void setWidthField(Integer w) {
		widthField.setText(w.toString());
	}

	public void setLengthField(Integer l) {
		lengthField.setText(l.toString());
	}

	public JTextField getWidthField() {
		return widthField;
	}

	public JTextField getLengthField() {
		return lengthField;
	}

	private JLabel getJLabel(String text) {
		JLabel temp = new JLabel();
		temp.setForeground(Color.white);
		temp.setText(text);

		return temp;
	}
}
